package com.monitor.common;

import com.monitor.dao.SysUserDao;
import com.monitor.dao.TaskInfoDao;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

/**
 * @ClassName InitUser
 * @Package com.monitor.common
 * @Description 初始化库
 * @Author zhixingbai
 * @Create 2018/10/1511:49
 */
@Component
public class InitSetting {
    private final Logger logger=LoggerFactory.getLogger(this.getClass());
    @Autowired
    private SysUserDao sysUserDao;
    @Autowired
    private TaskInfoDao taskInfoDao;

    @PostConstruct
    private void init(){
        int count=sysUserDao.selectCount();
        if(count==0) {
            sysUserDao.initUser();
            logger.info("初始化用户成功！");
        }
         int taskCount=taskInfoDao.selectCount();
        if(taskCount==0){
            taskInfoDao.initTask();
            logger.info("初始化任务成功！");
        }
    }

}
